package com.example;

public enum ErrorEnum {

    COMMON_ERROR("0000","服务超时"),
    LACK_PARAMETER("0001","缺少参数"),
    LACK_PHONE("0002","缺少手机号"),
    LACK_TOKEN("0003","缺少token"),
    ;
    private final String code;
    private final String message;

    ErrorEnum(String code,String message){
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorEnum getByCode(String code){
        for (ErrorEnum errorEnum : ErrorEnum.values()) {
            if(errorEnum.getCode().equals(code)){
                return errorEnum;
            }
        }
        return null;
    }

}
